<?php
//$appStoreStr = Yii::t('site','appStore');
$operations = Blyn::app()->getActiveApp()->getOperations(array('user' => Blyn::app()->getCurrentUser()));
$items = array();
$activeSpace = Blyn::app()->getActiveSpace();
$user = Blyn::app()->getCurrentUser();
$adminRole = $activeSpace->getSpaceEngine()->getRole(BRole::Role_App_Admin);
$isShowChangePassword = false;
if ($activeSpace->getSpaceType()->getName() == BSpaceGroup::Group_SpaceType_PersonalSpace && $user->isMemberOf($adminRole)) {
                    $isShowChangePassword = true;
}

foreach ($operations as $id => $opp) {
    $item = array();
    $item['active'] = '';
    $menuStr = Yii::t('site', $opp->getName(BEntity::Name_DisplayName));
    //if (Blyn::app()->getActiveApp()->getId() != Blyn::app()->getCurrentUser()->getPersonalSpace()->getApp('BPersonalApp')->getId()) {
    if ($opp->getName(BEntity::Name_DisplayName) == "Resources") {
        //$url = $opp->getUIManager()->getUrl();
        $item['url'] = $opp->getUIManager()->getLinkFromUrl();
//        $item['label'] = $opp->getName(BEntity::Name_DisplayName);
    } else {
        //$item['url'] = $opp->getUIManager()->getUrl(array('ajaxLink' => array('name' => $opp->getDisplayName())));
        $item['url'] = $opp->getUIManager()->getAjaxLink($menuStr);
//        $item['url'] = $opp->getUIManager()->getAjaxLink($opp->getName(BEntity::Name_DisplayName));
//        $item['label'] = $opp->getName(BEntity::Name_DisplayName);
    }
    $item['label'] = $menuStr;
    //$item['active'] = FALSE;

    $activeOperation = Blyn::app()->getActiveOperation();

    if ($activeOperation instanceof BOperation && $opp->getId() == $activeOperation->getId())
        $item['active'] = 'active';
    // $item['active'] = TRUE;
    $displayName = $opp->getName(BEntity::Name_DisplayName);
    if ($opp->getName(BEntity::Name_DisplayName) != "changePassword" || $isShowChangePassword)
        array_push($items, $item);
}

//}
?>
<div style="background-color: white">
    <div class="container" style="margin: auto;padding-top: 15px">
        <ul class="nav nav-pills">
            <?php foreach ($items as $item) { ?>
                <li class=<?php echo $item['active']; ?>>
                    <?php if ($item['label'] == 'Resources') { ?>
                        <a href='<?php echo $item['url']; ?>'><?php echo $item['label']; ?></a>;
                        <?php
                    } else {
                        echo $item['url'];
                    }
                    ?>
                </li>  
            <?php } ?>
        </ul>
    </div>
    
</div>

